package cn.com.cym.gamezao.web.demo;

import cn.com.cym.gamezao.annotation.AuthToken;
import cn.com.cym.gamezao.base.BaseController;
import cn.com.cym.gamezao.base.BaseService;
import cn.com.cym.gamezao.entity.demo.CeiShi;
import cn.com.cym.gamezao.service.demo.CeiShiService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@Api(tags = "CeiShi")
@RestController
@RequestMapping(value = "ceiShi")
@AuthToken(rule = "demo.ceiShi")
public class CeiShiController extends BaseController<CeiShi> {
    final CeiShiService thisService;

    public CeiShiController(CeiShiService ceiShiService){
        this.thisService=ceiShiService;
    }

    @Override
    public BaseService<CeiShi> getService() {
        return this.thisService;
    }

    @ApiImplicitParam(name = "ceiShi", value = "ceiShi", required = true,dataType = "CeiShi")
    @ApiOperation(value = "新建")
    @ApiOperationSupport(order = 1, author = "mr.chen")
    @PostMapping()
    @AuthToken(rule = "add")
    public ResponseEntity<?> add(@RequestBody CeiShi ceiShi){
        final CeiShi ceiShiStore = this.thisService.save(ceiShi);
        return ResponseEntity.ok(ceiShiStore);
    }

    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "id",paramType = "path", required = true,dataType = "Long"),
            @ApiImplicitParam(name = "ceiShi", value = "ceiShi", required = true,dataType = "CeiShi")})
    @ApiOperation(value = "更新")
    @ApiOperationSupport(order = 3, author = "mr.chen")
    @PutMapping("/{id}")
    @AuthToken(rule = "update")
    public ResponseEntity<?> update(@RequestBody CeiShi ceiShi,@PathVariable Long id){
        final CeiShi ceiShiStore = this.thisService.update(ceiShi,id);
        return ResponseEntity.ok(ceiShiStore);
    }

}